using System.Collections.Generic;

namespace ActiveRecordSample.Entities
{
	// Business class SalesOrderHeader generated from SalesOrderHeader
	// shvadskd [2008-10-20] Created

	using System;
	using System.ComponentModel;
	using Castle.ActiveRecord;

   [ActiveRecord("SalesLT.SalesOrderHeader")]
	public  class SalesOrderHeader 
		: ActiveRecordValidationBase<SalesOrderHeader> 
	{

		#region Property_Names

		public static string Prop_SalesOrderID = "SalesOrderID";
		public static string Prop_RevisionNumber = "RevisionNumber";
		public static string Prop_OrderDate = "OrderDate";
		public static string Prop_DueDate = "DueDate";
		public static string Prop_ShipDate = "ShipDate";
		public static string Prop_Status = "Status";
		public static string Prop_OnlineOrderFlag = "OnlineOrderFlag";
		public static string Prop_SalesOrderNumber = "SalesOrderNumber";
		public static string Prop_PurchaseOrderNumber = "PurchaseOrderNumber";
		public static string Prop_AccountNumber = "AccountNumber";
		public static string Prop_Customer = "Customer";
		public static string Prop_ShipToAddress = "ShipToAddress";
		public static string Prop_BillToAddress = "BillToAddress";
		public static string Prop_ShipMethod = "ShipMethod";
		public static string Prop_CreditCardApprovalCode = "CreditCardApprovalCode";
		public static string Prop_SubTotal = "SubTotal";
		public static string Prop_TaxAmt = "TaxAmt";
		public static string Prop_Freight = "Freight";
		public static string Prop_TotalDue = "TotalDue";
		public static string Prop_Comment = "Comment";
		public static string Prop_rowguid = "rowguid";
		public static string Prop_ModifiedDate = "ModifiedDate";

		#endregion

		#region Private_Variables

		private int _salesorderid;
		private byte _revisionNumber;
		private DateTime _orderDate;
		private DateTime _dueDate;
		private DateTime? _shipDate;
		private byte _status;
		private bool _onlineOrderFlag;
		private string _salesOrderNumber;
		private string _purchaseOrderNumber;
		private string _accountNumber;
		private Customer _customer;
		private Address _shipToAddress;
		private Address _billToAddress;
		private string _shipMethod;
		private string _creditCardApprovalCode;
		private System.Decimal _subTotal;
		private System.Decimal _taxAmt;
		private System.Decimal _freight;
		private System.Decimal _totalDue;
		private string _comment;	
		private DateTime _modifiedDate;

		private IList<SalesOrderDetail> _SalesOrderDetail = new List<SalesOrderDetail>();

		#endregion

		#region Constructors

		public SalesOrderHeader()
		{
		}

		public SalesOrderHeader(
			int p_salesorderid,
			byte p_revisionNumber,
			DateTime p_orderDate,
			DateTime p_dueDate,
			DateTime? p_shipDate,
			byte p_status,
			bool p_onlineOrderFlag,
			string p_salesOrderNumber,
			string p_purchaseOrderNumber,
			string p_accountNumber,
			Customer p_customer,
			Address p_shipToAddress,
			Address p_billToAddress,
			string p_shipMethod,
			string p_creditCardApprovalCode,
			System.Decimal p_subTotal,
			System.Decimal p_taxAmt,
			System.Decimal p_freight,
			System.Decimal p_totalDue,
			string p_comment,
			byte[] p_rowguid,
			DateTime p_modifiedDate)
		{
			_salesorderid = p_salesorderid;
			_revisionNumber = p_revisionNumber;
			_orderDate = p_orderDate;
			_dueDate = p_dueDate;
			_shipDate = p_shipDate;
			_status = p_status;
			_onlineOrderFlag = p_onlineOrderFlag;
			_salesOrderNumber = p_salesOrderNumber;
			_purchaseOrderNumber = p_purchaseOrderNumber;
			_accountNumber = p_accountNumber;
			_customer = p_customer;
			_shipToAddress = p_shipToAddress;
			_billToAddress = p_billToAddress;
			_shipMethod = p_shipMethod;
			_creditCardApprovalCode = p_creditCardApprovalCode;
			_subTotal = p_subTotal;
			_taxAmt = p_taxAmt;
			_freight = p_freight;
			_totalDue = p_totalDue;
			_comment = p_comment;		
			_modifiedDate = p_modifiedDate;
		}

		#endregion

		#region Properties

		[PrimaryKey("SalesOrderID", Access = PropertyAccess.NosetterLowercaseUnderscore)]
		public int SalesOrderID
		{
			get { return _salesorderid; }
		}

		[Property("RevisionNumber", NotNull = true)]
		public byte RevisionNumber
		{
			get { return _revisionNumber; }
			set { _revisionNumber = value; }
		}

		[Property("OrderDate", NotNull = true)]
		public DateTime OrderDate
		{
			get { return _orderDate; }
			set { _orderDate = value; }
		}

		[Property("DueDate", NotNull = true)]
		public DateTime DueDate
		{
			get { return _dueDate; }
			set { _dueDate = value; }
		}

		[Property("ShipDate")]
		public DateTime? ShipDate
		{
			get { return _shipDate; }
			set { _shipDate = value; }
		}

		[Property("Status", NotNull = true)]
		public byte Status
		{
			get { return _status; }
			set { _status = value; }
		}

		[Property("OnlineOrderFlag", NotNull = true)]
		public bool OnlineOrderFlag
		{
			get { return _onlineOrderFlag; }
			set { _onlineOrderFlag = value; }
		}

		[Property("SalesOrderNumber", NotNull = true, Length = 25)]
		public string SalesOrderNumber
		{
			get { return _salesOrderNumber; }
			set { _salesOrderNumber = value; }
		}

		[Property("PurchaseOrderNumber", Length = 25)]
		public string PurchaseOrderNumber
		{
			get { return _purchaseOrderNumber; }
			set { _purchaseOrderNumber = value; }
		}

		[Property("AccountNumber", Length = 15)]
		public string AccountNumber
		{
			get { return _accountNumber; }
			set { _accountNumber = value; }
		}

		[BelongsTo("CustomerID", Type = typeof(Customer))]
		public Customer BelongsToCustomer
		{
			get { return _customer; }
			set { _customer = value; }
		}

		[BelongsTo("ShipToAddressID", Type = typeof(Address))]
		public Address ShipToAddress
		{
			get { return _shipToAddress; }
			set { _shipToAddress = value; }
		}

		[BelongsTo("BillToAddressID", Type = typeof(Address))]
		public Address BillToAddress
		{
			get { return _billToAddress; }
			set { _billToAddress = value; }
		}

		[Property("ShipMethod", NotNull = true, Length = 50)]
		public string ShipMethod
		{
			get { return _shipMethod; }
			set { _shipMethod = value; }
		}

		[Property("CreditCardApprovalCode", Length = 15)]
		public string CreditCardApprovalCode
		{
			get { return _creditCardApprovalCode; }
			set { _creditCardApprovalCode = value; }
		}

		[Property("SubTotal", NotNull = true)]
		public System.Decimal SubTotal
		{
			get { return _subTotal; }
			set { _subTotal = value; }
		}

		[Property("TaxAmt", NotNull = true)]
		public System.Decimal TaxAmt
		{
			get { return _taxAmt; }
			set { _taxAmt = value; }
		}

		[Property("Freight", NotNull = true)]
		public System.Decimal Freight
		{
			get { return _freight; }
			set { _freight = value; }
		}

		[Property("TotalDue", NotNull = true)]
		public System.Decimal TotalDue
		{
			get { return _totalDue; }
			set { _totalDue = value; }
		}

		[Property("Comment")]
		public string Comment
		{
			get { return _comment; }
			set { _comment = value; }
		}     

		[Property("ModifiedDate", NotNull = true)]
		public DateTime ModifiedDat
		{
			get { return _modifiedDate; }
			set { _modifiedDate = value; }
		}

	[HasMany(typeof(SalesOrderDetail), Table="SalesOrderDetail", ColumnKey="SalesOrderID",Lazy = true)]
	public IList<SalesOrderDetail> SalesOrderDetail
	{
	    get { return _SalesOrderDetail; }
	    set { _SalesOrderDetail = value; }
	}
		#endregion

	} // SalesOrderHeader
}

